#!/usr/bin/env python

from subprocess import Popen, PIPE

vars = [ 'corrupt-packets', 'deferred-cache-inserts', 'deferred-cache-lookup',
'latency', 'packetcache-hit', 'packetcache-miss', 'packetcache-size',
'qsize-q', 'query-cache-hit', 'query-cache-miss', 'recursing-answers',
'recursing-questions', 'servfail-packets', 'tcp-answers', 'tcp-queries',
'timedout-packets', 'udp-answers', 'udp-queries', 'udp4-answers',
'udp4-queries', 'udp6-answers', 'udp6-queries' ]

rvars = {}
cmd = ['/usr/bin/pdns_control', 'show', '*']

for l in Popen(cmd, stdout=PIPE).communicate()[0].decode().rstrip().split(','):
    v = l.split('=')
    if len(v) > 1:
    	rvars[v[0]] = v[1]

print("<<<app-powerdns>>>")

for k in vars:
    print(rvars[k])
